"Get out of VI's compatible mode..
set nocompatible

""""""""""""""""""""""""""""""""""""""""
"	General
""""""""""""""""""""""""""""""""""""""""

"Set mapleader
let mapleader = ","
let g:mapleader = ","

"Have the mouse enabled all the time:
set mouse=a

"Guick load vimrc
"Fast reloading of the .vimrc
map <silent> <leader>ss :source ~/.vimrc<cr>
"Fast editing of .vimrc
map <silent> <leader>ee :e ~/.vimrc<cr>
"When .vimrc is edited, reload it
autocmd! bufwritepost .vimrc source ~/.vimrc

"Fast saving
nmap <silent> <leader>ww :w<cr>
nmap <silent> <leader>wf :w!<cr>
	" save all window
nmap <silent> <leader>wa :wall<cr>

"Fast quiting
nmap <silent> <leader>qw :wq<cr>
nmap <silent> <leader>qf :q!<cr>
nmap <silent> <leader>qq :q<cr>
nmap <silent> <leader>qa :qa<cr>

"Fast Bg
nmap <leader>z <C-Z>
nmap <leader>fs <leader>ww<leader>z

"Fast Edit
nmap <leader>ef : e 

"Fast remove highlight search
nmap <silent> <leader><cr> :noh<cr>

"Fast Split Window
nmap <silent> <leader>vs : vsplit 
nmap <silent> <leader>hs : split 
nmap <silent> <leader>wc : close<cr>

"Fash Buffer 
nmap <silent> <leader>bn : bNext<cr>
nmap <silent> <leader>bp : bprevious<cr>
nmap <silent> <leader>bl : ls<cr>


"Fast redraw
nmap <silent> <leader>rr :redraw!<cr>

"Fast fold
nmap <silent> <leader>>> :foldclose<cr>
nmap <silent> <leader><< :foldopen<cr>

filetype off                

"Set to auto read when a file is changed from the outside
set autoread

"set line number
set nu

"show cursor in line an column
set cursorline
set cursorcolumn

"syntax highlight
syntax enable
syntax on

"自动对齐，也就是把当前行的对起格式应用到下一行；依据上面的对起格式，智能的选择对齐方式"
set autoindent
set smartindent
"设直TAB键为四个空格；设置当行之间交错时使用四个空格"
set tabstop=4
set shiftwidth=4
"设置匹配，类似当输入一个左括号时会匹配相应的那个右括号"
"set showmatch
"在编辑过程中，在右下角显示光标位置的状态行"
set ruler

"configure colortheme
colorscheme  molokai
set background=dark
let g:molokai_original = 1
let g:rehash256 = 1

"set font
set guifont=WenQuanYi\ Micro\ Hei\ Mono\ 12


"set netrw
let g:netrw_winsize = 30
nmap <silent> <leader>fe :Sexplore!<cr>


"Smart way to move btw. windows
nmap <C-j> <C-W>j
nmap <C-k> <C-W>k
nmap <C-h> <C-W>h
nmap <C-l> <C-W>l

"Tab configuration
map <leader>tn :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
map <leader>th :tabp<cr>
map <leader>tl :tabn<cr>

"Window Configuration


"Session Config
map <leader>ms :mksession
map <leader>sc :source 

" Search Config """"""""""" 
"Ignore case when searching
set ignorecase

"Include search
set incsearch

"Highlight search things
set hlsearch


" Other Auxiliary
""""""""""""""""""""""""""""""""""""""""



""""""""""""""""""""""""""""""""""""""""
"	End of General
""""""""""""""""""""""""""""""""""""""""






""""""""""""""""""""""""""""""""""""""""
"	Vundle Configuration
""""""""""""""""""""""""""""""""""""""""

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
" call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe'

Plugin 'easymotion/vim-easymotion'
Plugin 'kien/ctrlp.vim'
Plugin 'majutsushi/tagbar'
Plugin 'vim-scripts/taglist.vim'
Plugin 'powerline/powerline'
Plugin 'tpope/vim-surround'
Plugin 'mbbill/undotree'
Plugin 'scrooloose/syntastic'
Plugin 'bling/vim-airline'

Plugin 'scrooloose/nerdcommenter'
Plugin 'sjl/gundo.vim'

Plugin 'godlygeek/tabular'

" Track the engine.
Plugin 'SirVer/ultisnips'

" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'

Plugin 'vim-scripts/Visual-Mark'

Plugin 'ervandew/supertab'

Plugin 'fholgado/minibufexpl.vim'


call vundle#end()            " required
"Enable filetype plugin
filetype on
filetype plugin on
filetype indent on
filetype plugin indent on    

""""""""""""""""""""""""""""""""""""""""
"	End of Vundle Configuration
""""""""""""""""""""""""""""""""""""""""



""""""""""""""""""""""""""""""""""""""""
"	Plugins Configuration
""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""
" NERDTree Setting	"
"""""""""""""""""""""
nmap <silent> <leader>tt :NERDTreeToggle<cr>
nnoremap <F5> :NERDTree<cr>
let g:NERDTreeWinPos="left"
let g:NERDTreeWinSize=15
let g:NERDTreeShowLineNumbers=1
let g:neocomplcache_enable_at_startup = 1

"""""""""""""""""""""
" Tagbar Setting	"
"""""""""""""""""""""
nmap <silent> <leader>tg :TagbarToggle<cr>
nmap <F8> :TagbarToggle<cr>
let g:tagbar_width = 20


"""""""""""""""""""""
" Taglist Setting	"
"""""""""""""""""""""
nmap <silent> <leader>tgl :TlistToggle<cr>
let g:Tlist_WinWidth = 25
let g:Tlist_Use_Right_Window = 1
let Tlist_Show_One_File = 1


"""""""""""""""""""""
" Ultisnips Setting	"
"""""""""""""""""""""
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
"let g:UltiSnipsExpandTrigger="<tab>"
"let g:UltiSnipsJumpForwardTrigger="<c-b>"
"let g:UltiSnipsJumpBackwardTrigger="<c-z>"
"let g:ycm_use_ultisnips_completer = 1

" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'

" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"

" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"


"""""""""""""""""""""""""
" NERDCommenter Setting	"
"""""""""""""""""""""""""
" <leader>cc
" <leader>cu
" <leader>c<space>
" <leader>cs
" <leader>ca	" Change Comment method !!!


"""""""""""""""""""""
" Tabular Setting	"
"""""""""""""""""""""
nmap <Leader>a&     : Tabularize /&<CR>
vmap <Leader>a&     : Tabularize /&<CR>
nmap <Leader>a=     : Tabularize /=<CR>
vmap <Leader>a=     : Tabularize /=<CR>
nmap <Leader>a,     : Tabularize /,<CR>
vmap <Leader>a,     : Tabularize /,<CR>
nmap <Leader>a,,    : Tabularize /,\zs<CR>
vmap <Leader>a,,    : Tabularize /,\zs<CR>
nmap <Leader>a<Bar> : Tabularize /<Bar><CR>
vmap <Leader>a<Bar> : Tabularize /<Bar><CR>


"""""""""""""""""""""""
" Gundo     Setting   "
"""""""""""""""""""""""
nmap <silent> <leader>gu : GundoToggle <cr>
let g:gundo_width = 20


"""""""""""""""""""""""
" VisualMark Setting  "
"""""""""""""""""""""""
nmap <leader>mn <F2>


"""""""""""""""""""""""
" easyMotion Setting  "
"""""""""""""""""""""""
" <leader><leader>j



"""""""""""""""""""""""""
" surround.vim Setting  "
"""""""""""""""""""""""""
" 'hello' -> cs'" -> "hello"
" 'hello' -> ds'  -> hello


"""""""""""""""""""""""""
" supertab Setting  	"
"""""""""""""""""""""""""
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"



"""""""""""""""""""""""""
" MiniBufExpl Setting  	"
"""""""""""""""""""""""""
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplMapWindowNavArrow = 1
let g:miniBufExplMapWindowNavVim = 1 
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplMapCTabSwitchWindows = 1 
let g:miniBufExplModSelTarget = 1  
"let g:miniBufExplVSplit = 1  
"let g:miniBufExplMinSize = 15
nmap <silent> <leader>mo : MBEOpen<cr>
nmap <silent> <leader>mc : MBEClose<cr>


